<?php
/**
 * Created by PhpStorm.
 * User: Lee
 * Date: 2020/1/3
 * Time: 9:51
 */
namespace App\Repositories\Backend\System;
use App\Common\Utils\BaseRepository;
use App\Models\Backend\System\Log;
use Carbon\Carbon;

/**
 * 系统管理-日志管理 (仓库)
 */
class LogRepository extends BaseRepository
{
    /**
     * @var Log $model
     */
    protected $model;

    public function __construct(Log $log)
    {
        $this->model = $log;
    }

    //清除3个月之前的数据
    public function deleteLogsBeforeThreeMonths()
    {
        $threeMonths = Carbon::parse('-3 months')->toDateTimeString();
        $this->model::where('optime','<',$threeMonths)->delete();
    }
}
